﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using AnguaRPGEngine.Library.Interfaces;

namespace AnguaRPGEngine.Library.Parts
{
    public class Markup : IPart
    {
        #region Private Properties
        #region IPart Members
        private Rectangle _Bounds = new Rectangle();
        private string _ImageName;
        private string _Keywords;
        private Point _Location;
        private string _Name;
        private float _Rotation = 0f;
        private Size _Size;
        private bool _VisibleToPlayers;
        #endregion
        #endregion
        #region Public Properties
        #region IPart Members
        #region Bounds
        public Rectangle Bounds
        {
            get
            {
                return _Bounds;
            }
        }
        #endregion
        #region ImageName
        public string ImageName
        {
            get
            {
                return _ImageName;
            }
            set
            {
                _ImageName = value;
            }
        }
        #endregion
        #region Keywords
        public string Keywords
        {
            get
            {
                return _Keywords;
            }
            set
            {
                _Keywords = value;
            }
        }
        #endregion
        #region Location
        public Point Location
        {
            get
            {
                return _Location;
            }
            set
            {
                _Location = value;
                _Bounds = new Rectangle(_Location.X, _Location.Y, Size.Width - 1, Size.Height - 1);
            }
        }
        #endregion
        #region Name
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }
        #endregion
        #region PartType
        public PartTypes PartType
        {
            get
            {
                return PartTypes.Markup;
            }
        }
        #endregion
        #region Rotation
        public float Rotation
        {
            get
            {
                return _Rotation;
            }
            set
            {
                _Rotation = value;
            }
        }
        #endregion
        #region Size
        public Size Size
        {
            get
            {
                return _Size;
            }
            set
            {
                _Size = value;
                _Bounds = new Rectangle(_Location.X, _Location.Y, (Size.Width - 1), (Size.Height - 1));
            }
        }
        #endregion
        #region VisibleToPlayers
        public bool VisibleToPlayers
        {
            get
            {
                return _VisibleToPlayers;
            }
            set
            {
                _VisibleToPlayers = value;
            }
        }
        #endregion
        #endregion
        #endregion
        #region Public Methods
        #region IPart Members
        #region Contains
        public bool Contains(Point point)
        {
            return (_Bounds.Left <= point.X && _Bounds.Right >= point.X
               && _Bounds.Top <= point.Y && _Bounds.Bottom >= point.Y);
        }
        #endregion
        #region ClonePart
        public IPart ClonePart()
        {
            Markup mu = new Markup();
            mu._Bounds = new Rectangle(_Bounds.Left, _Bounds.Top, _Bounds.Width, _Bounds.Height);
            mu._ImageName = _ImageName;
            mu._Keywords = _Keywords;
            mu._Location = new Point(_Location.X, _Location.Y);
            mu._Name = _Name;
            mu._Rotation = _Rotation;
            mu._Size = new Size(_Size.Width, _Size.Height);
            mu._VisibleToPlayers = _VisibleToPlayers;
            return mu;
        }
        #endregion
        #region LocatedIn
        public bool LocatedIn(Rectangle rect)
        {
            return (_Location.X + (Size.Width / 2) >= rect.X && _Location.X + (Size.Width / 2) <= rect.X + rect.Width
                && _Location.Y + (Size.Height / 2) >= rect.Y && _Location.Y + (Size.Height / 2) <= rect.Y + rect.Width);
        }
        #endregion
        #endregion
        #endregion
    }
}
